<template>
	<view class="content">
		<image :src="detail.bgImage" mode="widthFix" style="width: 100%;border: none;"></image>
		<view class="detail" :style="{backgroundColor:detail.bgColor}">
			<view v-for="(item,index) in detail.productDtos" :key="index" :class="[index%2==0?'item':'item_']" @tap="goDetail(item.id)">
				<image :src="item.image" style="margin-top: 20upx;width: 280upx;height: 280upx;" mode="aspectFill" lazy-load></image>
				<view class="name">{{item.name}}</view>
				<view class="price">￥<view style="font-weight: 800;font-size: 32upx;">{{item.price}}</view></view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '../../common/api.js';
	import {
		get_
	} from '../../common/request.js';
	export default {
		data() {
			return {
				detail: {}
			}
		},
		onLoad(option) {
			this.initData(option.id)
		},
		methods: {
			initData(id) {
				get_(api.ACTIVITY_DETAIL + id).then(res => {
					uni.setNavigationBarTitle({
						title: res.data.name
					})
					this.detail = res.data
				})
			},
			goDetail(id){
				uni.navigateTo({
					url:'../product/detail?id='+id
				})
			}
		}
	}
</script>

<style>
	.detail {
		padding: 30upx 50upx;
		box-sizing: border-box;
		flex-wrap: wrap;
	}

	.item {
		background-color: #FFFFFF;
		border-radius: 10upx;
		width: 315upx;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 20upx;
	}

	.item_ {
		background-color: #FFFFFF;
		border-radius: 10upx;
		width: 315upx;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 20upx;
		margin-left: 20upx;
	}

	.name {
		width: 100%;
		padding: 0 20upx;
		box-sizing: border-box;
		color: #333333;
		margin-top: 20upx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}
	
	.price{
		width: 100%;
		padding: 10upx 20upx;
		box-sizing: border-box;
		color: #FE0036;
		font-size: 26upx;
		align-items: flex-end;
	}
</style>
